# _*_ coding:utf-8 _*_
import time

from selenium.webdriver import Keys

from pages.base_page import BasePage
from selenium.webdriver.common.by import By


# pages/login_page.py,页面对象模型，子类，继承base_page,存放具体的页面属性
class BaoGuanDingDanPage(BasePage):
    # 新增报关订单路径
    BAOGUANDINGDAN_SPAN = (By.XPATH, '//span[text()="报关订单"]')
    BAOGUANDINGDANGUANLI_SPAN = (By.XPATH, '//li/span[text()="报关订单管理"]')
    XINZENGBAOGUANDINGDING_BUTTON = (By.XPATH, '//button/span[text()="新增报关订单"]')

    # 新增报关报关订单页面

    # 电子委托协议
    DIANZIWEITUOXIEYI = (By.ID,'rc-tabs-1-tab-电子报关委托协议')
    WEITUOXIEYI_INPUT = (By.CSS_SELECTOR,'div>span>#ecuAttachment')
    CHECKBOS_div = (By.ID,"ecuCheck")

    #基本信息
    JIBENXINXI = (By.ID,'rc-tabs-1-tab-基本信息')
    JUANGUANFANGSHI_INPUT = (By.ID,"regulation")
    XUKEZHENGHAO_INPUT = (By.CSS_SELECTOR,"#licenseNo > span > input")
    BEIANHAO_INPUT = (By.CSS_SELECTOR,"#manualNo > span > input")
    JIEGUANRIQI_TIME = (By.ID,"closingDate")
    MAOYIGUOBIE_INPUT = (By.ID,'tradeCountry')
    ZHENGMIANXIGNZHI_INPUT = (By.ID,"cutModeKey")
    JIAOHUOQI_INPUT = (By.ID,"deliveryDate")
    DUANYIZHUANG_INPUT = (By.ID,"moreLess")
    HETONGXIEYIHAO_INPUT = (By.CSS_SELECTOR,"#contrNo > span > input")

    #交易方信息
    JIAOYIFANGXINXI = (By.ID,'rc-tabs-1-tab-交易方信息')
    #境外收发货人信息
    QIYEMINGCHENG_ENG_INPUT = (By.CSS_SELECTOR,"#overseasConsigneeEname > span > input")
    LIANXIFANGSHI_XUANZE = (By.ID,'rc_select_22')
    LIANXIFANGSHI_XUANZE_ONT = (By.ID,'rc_select_22_list_0')
    LIANXIFANGSHI_INPUT = (By.CSS_SELECTOR,'#overseasInfo1 > input')
    JINGWAISHOUFARENDIZHI_INPUT = (By.CSS_SELECTOR,"#overseasConsigneeCode > span > input")
    XIANGXIDIZHI_CGUOJIA = (By.ID,'rc_select_23')
    XIANGXIDIZHI_JUTI = (By.CSS_SELECTOR,'#overseasInfo2 > input')
    # 生产销售单位信息
    QIYEMIGNCHEN_INPUT = (By.CSS_SELECTOR,'#ownerName > span > input')
    SHEHUIXINYONGDAIMA = (By.CSS_SELECTOR,'#ownerCodeScc > span > input')
    HAIGUANBIANHAO = (By.CSS_SELECTOR,'#ownerCode > span > input')
    LIANXIFANGSHI_XUANZE_ONT2 = (By.ID,'rc_select_25')
    LIANXIFANGSHI_INPUT2 = (By.CSS_SELECTOR,'#ownerInfo1 > input')

    # 运输信息
    YUNSHUXINXI = (By.ID,'rc-tabs-1-tab-基本信息')
    YUNSHUFANGSHI = (By.ID,'transportationModeKey')
    YUNDIGUO = (By.ID,'arrivalCountry')
    ZHIYUNGAN = (By.ID,'distinatePort')
    QIYUNGAN = (By.ID,'domesticPort')
    MUDIGAN = (By.ID,'overseasPort')
    JINGZHONG = (By.XPATH,'//input[@placeholder*="输入净重"]')
    MAOZHONG = (By.XPATH,'//input[@placeholder*="输入毛重"]')
    BAOZHUANGZHONGLEI = (By.ID,'package')
    JIANSHU = (By.ID,'packNo')
    BIAOJIMAITMA = (By.CSS_SELECTOR,'#markNo > span > input')

    #费用信息
    FEIYONGXINXI = (By.ID,'rc-tabs-1-tab-费用信息')
    CHENGJIAOFANGSHI = (By.ID,'tradeTerms')
    FUKUANFANGSHI = (By.ID,'payMethod')
    BIZHI = (By.ID,'tradeCurr')

    #其他信息
    QITAXINXI = (By.ID,'rc-tabs-1-tab-其他信息')
    HUOWUCUNFANGDIDIAN = (By.CSS_SELECTOR,'#goodsPlace > span > input')
    BAOGUANDANBEIZHU = (By.CSS_SELECTOR,'#noteS > span > input')

    #商品信息
    SHANGPINGXINXI = (By.ID,'rc-tabs-1-tab-商品信息')
    XINZHESHANGPINGXINXI = (By.XPATH,'//div/button/span[text()="新增商品信息"]')
    SHANGPINGBIANMA = (By.ID,'codeTS')
    SHANGPINGMINGCHEN = (By.CSS_SELECTOR,'#gName > span > input')
    SHANGPINGMINGCHEN_ENG = (By.CSS_SELECTOR,'#gNameEng > span > input')
    GUIGEXINGHAO = (By.CSS_SELECTOR,'#specification > span > input')
    JIJIAFANGSHI_DANJIA = (By.XPATH,'//span[text()="锚定单价"]')
    JIAJIFANGSHI_ZONGJIA =(By.XPATH,'//span[text()="锚定总价"]')
    ZONGJIA = (By.ID,'declTotal')
    CHENJIAOSHULIANG = (By.ID,'gQty')
    DANJIA = (By.ID,'declPrice')
    CHENGJIAODANWEI = (By.ID,'gUnit')
    SHANGPINGJINGZHONG = (By.XPATH,'//input[@placeholder*="输入商品净重"]')
    SHANGPINGMAOZHONG = (By.XPATH,'//input[@placeholder*="输入商品毛重"]')
    FADINGDIYIDANWEI = (By.XPATH,'//input[@placeholder*="输入法定第一数量"]')
    FADINGDIERDANWEI = (By.XPATH, '//input[@placeholder*="输入法定第二数量"]')
    JIAGONGCHENGPING = (By.CSS_SELECTOR,'#exgVersion > span > input')
    HUOHAO = (By.CSS_SELECTOR,'#exgNo > span > input')
    ZUIZHONGMUDIGUO = (By.ID,'destinationCountry')
    YUANCHANGUO = (By.ID,'originCountry')
    JINGNEIHUOYUANDI = (By.ID,'districtCode')
    ZHENGMIANFANGSHI = (By.ID,'dutyMode')
    #申报要素
    SHENBAOYAOSU = (By.XPATH,'//div/button/span[text()="申报要素"]')
    JIZHUANGXIANGHAO = (By.CSS_SELECTOR,'#containerId > span > input')
    JIZHUANGXIANGGUIGE = (By.ID,'containerMd')
    ZIZHONG = (By.ID,'containerWt')



    #集装箱信息
    JIZHUANGXIANGXINXI = (By.ID,'rc-tabs-1-tab-集装箱信息')
    XINZENJIZHUANGXIANGXINXI = (By.ID,'button/span[text()="新增集装箱信息"]')
    PINGXIANGBIAOSHI_TRUE = (By.XPATH,'//*[@id="lclFlag"]/label[1]')
    PINGXIANGBIAOSHI_FLASE = (By.XPATH,'//*[@id="lclFlag"]/label[2]')
    SHANGPINGXIANGHAOGUANXI = (By.XPATH,'//span[@placeholder*="选择商品项号关系"]')
    YIJIANQUANXUAN = (By.XPATH,'//button/span[text="一键全选"]')

    #新增报关订单路径
    def path_add(self):
        self.click(self.BAOGUANDINGDAN_SPAN[0],self.BAOGUANDINGDAN_SPAN[1],'报关订单')
        self.click(self.BAOGUANDINGDANGUANLI_SPAN[0],self.BAOGUANDINGDANGUANLI_SPAN[1],'报关订单管理')
        time.sleep(2)
        self.click(self.XINZENGBAOGUANDINGDING_BUTTON[0],self.XINZENGBAOGUANDINGDING_BUTTON[1],'新增报关订单')


    #电子报关委托协议模块
    def dianziweituoxieyi(self,path):
        time.sleep(2)
        self.click(self.DIANZIWEITUOXIEYI[0],self.DIANZIWEITUOXIEYI[1],'委托关系证明按钮')
        self.upload_file(self.WEITUOXIEYI_INPUT[0],self.WEITUOXIEYI_INPUT[1],path,'委托关系证明')
        self.click(self.CHECKBOS_div[0],self.CHECKBOS_div[1],'勾选同意按钮')

    # 基本信息
    def jibenxinxi(self,base_massage):
        time.sleep(2)
        self.click(self.JIBENXINXI[0],self.JIBENXINXI[1],'点击基本信息按钮')
        element = self.send_keys(self.JUANGUANFANGSHI_INPUT[0],self.JUANGUANFANGSHI_INPUT[1],"一般贸易",'监管方式')
        time.sleep(1)
        element.send_keys(Keys.ENTER)
